package com.zqxq.lottery.entity.o2o.order;

import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.po.order.OrderTicketPO;
import com.zqxq.lottery.entity.vo.order.OrderTicketVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 说    明：   订单出票
 * 创 建 人：	一刀·胡
 * 创建时间：	2018/3/22 12:04
 * 修 改 人：
 * 修改日期：
 **/
public class OrderTicketO2O {

    public static OrderTicketVO toVO(OrderTicketPO po) {
        if (po == null) {
            return null;
        }
        OrderTicketVO orderTicketVO = new OrderTicketVO();
        orderTicketVO.setId(DispatcherUtils.parseString(po.getId()));
        orderTicketVO.setOrderId(DispatcherUtils.parseString(po.getOrder_id()));
        orderTicketVO.setTicketUrl(po.getTicket_url());
        orderTicketVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        orderTicketVO.setUpdateTime(DispatcherUtils.parseDateTimeStr(po.getUpdate_time()));
        return orderTicketVO;
    }

    public static OrderTicketPO toPO(OrderTicketVO vo) {
        if (vo == null) {
            return null;
        }
        OrderTicketPO orderTicketPO = new OrderTicketPO();
        orderTicketPO.setId(DispatcherUtils.parseLong(vo.getId()));
        orderTicketPO.setOrder_id(DispatcherUtils.parseLong(vo.getOrderId()));
        orderTicketPO.setTicket_url(vo.getTicketUrl());
        orderTicketPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        orderTicketPO.setUpdate_time(DispatcherUtils.parseDateTime(vo.getUpdateTime()));
        return orderTicketPO;
    }

    public static List<OrderTicketVO> toVOList(List<OrderTicketPO> list){
        List<OrderTicketVO> result = new ArrayList<>();
        if(list != null && list.size() > 0){
            for(OrderTicketPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }

}
